'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with self work for additional information
 * regarding copyright ownership.  The ASF licenses self file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use self file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''
from base.graph.Node import Node
from base.java.Objects import Objects

#import java.util.Objects;

'''
 * Extension to the RDF Data model.
 * This class and any subclasses exist for experimentation and custom extensions.
 * There is no support for them within Apache Jena.
 * <p>
 * Extension nodes exist so that the machinery of datastructures (graphs, triples)
 * can be used.  There is no guarantee that processing Nodes (e.g. writing) will handle
 * extensions.
'''
from abc import ABC, abstractmethod

# 原本是 Node_Ext<X>
class Node_Ext(Node):

    # param X label
    # result protected
    @abstractmethod
    def Node_Ext(self, label):
        super().__init__(label)
    

    #@Override
    # param NodeVisitor v
    # result Object
    @abstractmethod
    def visitWith(self, v):
        return None
    

    # If the extension wants the node to match in memory graphs, self must be True
    # and extension type X must support value-based .equals() and .hashCode().
    #@Override
    # param 
    # result boolean
    @abstractmethod
    def isConcrete(self):
        return False
    

    # @SuppressWarnings("unchecked")
    # param 
    # result X
    @abstractmethod
    def get(self):
        return self.label

    def isExt(self):
        return True

    # @Override
    # return public int
    def hashCode(self):
        # final int
        prime = 31
        # int
        result = super().hashCode()
        result = prime * result + Objects.hash(self.label)
        return result

    # @Override
    # param Object
    # return boolean
    def equals(self, obj):
        if (self == obj):
            return True
        if (obj is None):
            return False
        # Class test - makes equality keep apart subclass instances.
        if (type(self).__name__ != type(obj).__name__):
            return False

        # Node_Ext<?> other = (Node_Ext<?>) obj;
        # return Objects.equals(label, other.label);
        return Objects.equals(self.label, obj.label)

